package com.zc.trendsDispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.trendsDispatch.domain.ChargeStationRealPowerHis;
import com.zc.trendsDispatch.service.IChargeStationRealPowerHisService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场站历史功率Controller
 * 
 * @author glb
 * @date 2023-12-14
 */
@RestController
@RequestMapping("/trendsDispatch/his")
public class ChargeStationRealPowerHisController extends BaseController
{
    @Autowired
    private IChargeStationRealPowerHisService chargeStationRealPowerHisService;

    /**
     * 查询场站历史功率列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeStationRealPowerHis chargeStationRealPowerHis)
    {
        startPage();
        List<ChargeStationRealPowerHis> list = chargeStationRealPowerHisService.selectChargeStationRealPowerHisList(chargeStationRealPowerHis);
        return getDataTable(list);
    }

    /**
     * 导出场站历史功率列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:export')")
    @Log(title = "场站历史功率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeStationRealPowerHis chargeStationRealPowerHis)
    {
        List<ChargeStationRealPowerHis> list = chargeStationRealPowerHisService.selectChargeStationRealPowerHisList(chargeStationRealPowerHis);
        ExcelUtil<ChargeStationRealPowerHis> util = new ExcelUtil<>(ChargeStationRealPowerHis.class);
        util.exportExcel(response, list, "场站历史功率数据");
    }

    /**
     * 获取场站历史功率详细信息
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:query')")
    @GetMapping(value = "/{chargeStationId}")
    public AjaxResult getInfo(@PathVariable("chargeStationId") Long chargeStationId)
    {
        return AjaxResult.success(chargeStationRealPowerHisService.selectChargeStationRealPowerHisByChargeStationId(chargeStationId));
    }

    /**
     * 新增场站历史功率
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:add')")
    @Log(title = "场站历史功率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeStationRealPowerHis chargeStationRealPowerHis)
    {
        return toAjax(chargeStationRealPowerHisService.insertChargeStationRealPowerHis(chargeStationRealPowerHis));
    }

    /**
     * 修改场站历史功率
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:edit')")
    @Log(title = "场站历史功率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeStationRealPowerHis chargeStationRealPowerHis)
    {
        return toAjax(chargeStationRealPowerHisService.updateChargeStationRealPowerHis(chargeStationRealPowerHis));
    }

    /**
     * 删除场站历史功率
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:his:remove')")
    @Log(title = "场站历史功率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chargeStationIds}")
    public AjaxResult remove(@PathVariable Long[] chargeStationIds)
    {
        return toAjax(chargeStationRealPowerHisService.deleteChargeStationRealPowerHisByChargeStationIds(chargeStationIds));
    }
}
